package BinomialHeap;

/**
 * HeapTime
 *

/*
 * Used to check the time it takes to perform each important action 
 *
 */

public class HeapTime
{


    public static long calculateTime(long start, long end){
    	return (end-start)/1000;
    }
    /**
     * MAIN
     */

    public static void main(String[] args) {

    	int maxLength = 1000;
    	int numOfRepeats=1000;
    	  
        long start = System.nanoTime(); // Get start time
        long end = System.nanoTime(); // Get end time
        long nothingTime;
        long insertTime;
        long containsTime;
        long averageTime=0;
        long overallTime=0;
        
        int elemForInsert = 0;
        int elemForContains = 0;
        int naboo=42;
                    
        System.out.println("Czech King for max length = " + maxLength);
        // DURATION OF NOTHING 
        System.out.print("duration of nothing in microseconds: ");
        nothingTime=calculateTime(start, end);
        System.out.println(nothingTime);

       BinomialHeap t = new BinomialHeap();    

            for(int i=0;i<maxLength;i++){
            	elemForInsert = (int) Math.round(Math.random() * maxLength);
            	t.insert(elemForInsert);
            }
            	
      
            // CHECK TIME FOR INSERT
            System.out.print("duration of insert in microseconds: ");
                elemForInsert = (int) Math.round(Math.random() * maxLength);
                naboo=numOfRepeats;
	            while(naboo>0){
	             
	                    start=System.nanoTime();
	                    t.insert(elemForInsert);
	                    end=System.nanoTime();
	                    insertTime=calculateTime(start, end);
	                    overallTime+=insertTime;
	                    naboo--;
	                    
	                }
	             averageTime=overallTime/numOfRepeats;
	             System.out.println("overall: " +overallTime+", average: " +averageTime);
        

            
            
            // CHECK TIME FOR CONTAINS 
            System.out.print("duration of contains in microseconds: ");
            naboo=numOfRepeats;
            averageTime=0;
            while(naboo>0){
		        elemForContains = (int) Math.round(Math.random() * maxLength);
		        start=System.nanoTime();
		        t.contains(elemForContains);
		        end=System.nanoTime(); 
		        containsTime=calculateTime(start, end);
		        overallTime+=containsTime;
		        naboo--;
            }
   
            averageTime=overallTime/numOfRepeats;
            System.out.println("overall: " +overallTime+", average: " +averageTime);
    }
}